@extends('home.layout.base')
@section('title', '个人中心')
@section('pluginstyle')
<script src="{{ asset('/dist/home/js/1102.js') }}"></script>
<link rel="stylesheet" href="{{ asset('/dist/home/css/qikoo_user.css') }}">
<link rel=stylesheet href="{{ asset('/dist/home/css/v3203b5.css') }}">
<link rel=stylesheet href="{{ asset('/dist/home/css/qiku.css') }}">
<link rel=stylesheet href="{{ asset('/dist/home/css/store.css') }}">
<link rel=stylesheet href="{{ asset('/dist/home/css/order.css') }}">
<link rel=stylesheet href="{{ asset('/dist/home/css/qikoo_user.css') }}">
<link rel=stylesheet href="{{ asset('/dist/home/css/widget_address.css') }}">
<script>var _isindex = 0;</script>
<style>
    body{
        background-color: #ffffff;
    }
</style>
<link rel="stylesheet" type="text/css" href="{{ asset('/dist/home/css/css.css') }}" />
<style>.zp_wrap{background-color:#F5F5F5;margin-top:18px;padding:13px;position:relative}.zp_list{height:75px;line-height:75px;margin-bottom:13px}.zp_l1{float:left;width:420px}.zp_none{float:left;text-align:center;width:40px}.zp_sanjiao{border:15px solid #fff;border-bottom:15px solid #F5F5F5;height:0;left:40px;position:absolute;top:-30px;width:0}.zp_list:last-child{margin-bottom:0}.cont li.gout{width:895px}</style>
<style type="text/css">
    .Caddress{height:auto}
</style>
@endsection
@section('content')
{{--开始模板--}}
<div class="c m-t-30" style="clear:both; width: 1241px; border: 1px solid #ccc">
    <div class="content mall_head">
        <div class=mall_cont>
            <div class=mall_modw>
                <div class=hd>
                    <h3>收货地址</h3>
                    <span style="color:red;font-size:14px;padding:10px">
                        温馨提示：为了保证您的权益，防止黄牛倒卖，订单进入正在配货状态将不能修改收货地址和发票信息！
                    </span>
                </div>
                <div class=bd>
                    <div class="consigneeinfo addr-box">
                        <div class="mod-consignee-info">
                            @foreach ($address as $addr)
                            <div class=" ">
                                <div>
                                    @if($addr->id == $addr_id)
                                    <input type='radio' name="addr_id" class="addr_id" value="{{ $addr->id }}" style="float:left" checked>
                                    @else
                                    <input type='radio' name="addr_id" class="addr_id" value="{{ $addr->id }}" style="float:left">
                                    @endif
                                </div>
                                <label>
                                    {{$addr->addr_consignee}}，&nbsp; {{$addr->addr_province}}&nbsp;{{$addr->addr_city}}&nbsp;{{$addr->addr_county}}&nbsp;{{$addr->addr_detail}}&nbsp;，{{$addr->addr_postcode}}&nbsp;，{{$addr->addr_tel}}
                                </label>
                                <span class="item-action">
                                    <a style="float: right;" class="action-edit" title="编辑" href="javascript:void(0);">编辑</a>
                                </span>
                                <div class="mod-consignee-info">
                                    <!--I NEED-->
                                    <form action="{{ url("/address/{$addr->id}/edit")}}" method="post">
                                        <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
                                        <div style="display: none;"  class="consignee-add" >
                                            <div class="add-row">
                                                <label class="consignee-add-label" for="consignee_add_realname">
                                                    <b>*</b>收货人姓名 
                                                </label>
                                                <input value="{{$addr->addr_consignee}}" name="addr_consignee"  class="consignee-add-text" placeholder="收货人姓名" type="text">
                                            </div>
                                            <div class="add-row m-t-10">
                                                <div class="consignee-add-label" for="consignee_add_province">
                                                    <b>*</b>地址 
                                                </div>
                                                <div class="city_edit_{{$addr->id}}">
                                                    <select class="prov" name="addr_province"></select>
                                                    <select class="city" disabled="disabled" name="addr_city"></select>
                                                    <select class="dist" disabled="disabled" name="addr_county"></select>
                                                </div>
                                                <textarea  class="consignee-add-address" name="addr_detail" placeholder="{{$addr->addr_detail}}" >{{$addr->addr_detail}}</textarea>
                                            </div>
                                            <div class="add-row m-t-10">
                                                <label class="consignee-add-label" for="consignee_add_postcode">邮政编码</label>
                                                <input name="addr_postcode" class="consignee-add-text"  value="{{$addr->addr_postcode}}" placeholder="6位邮政编码" type="text">
                                            </div>
                                            <div class="add-row m-t-10">
                                                <label class="consignee-add-label" for="consignee_add_mobile">
                                                    <b>*</b>手机号码 </label>
                                                <input value="{{$addr->addr_tel}}" name="addr_tel"  class="consignee-add-text" placeholder="11位手机号" type="text">
                                            </div>
                                            <div class="add-row m-t-10">
                                                <p class="m-t-20">
                                                    <input type='submit' class="mod-btn-green shou" value="保存" >
                                                    <input type='button' class="mod-btn-gray shou cancel" value="取消">
                                                </p>
                                            </div>
                                        </div>
                                    </form>
                                    <!--I NEED-->
                                </div>
                                @endforeach
                               {{-- 添加新地址 --}}
                                <div class="Caddress">
                                    <div class="open_new" style="width: 1000px;margin-right: 60px;">
                                        <button style="margin-right: 860px;" class="open_btn shou" onclick="javascript:onclick_open();">使用新地址</button>
                                    </div>
                                    <div class="shade_content" style="border: 1px solid #8CC657;display: none">
                                        <div class="col-xs-12 shade_colse">
                                            <button onclick="javascript:onclick_close();">x</button>
                                        </div>
                                        <div class="nav shade_content_div">
                                            <div class="col-xs-12 shade_title">
                                                新增收货地址
                                            </div>
                                            <div class="col-xs-12 shade_from">
                                                <form action="{{ url('/address/add') }}" method="post">
                                                    <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
                                                    <div class="col-xs-12">
                                                        <span class="span_style" id="" style="margin-right: 28px;">地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;区</span>
                                                        <div class="city_2">
                                                            <select class="prov" name="addr_province"></select>
                                                            <select class="city" disabled="disabled" name="addr_city"></select>
                                                            <select class="dist" disabled="disabled" name="addr_county"></select>
                                                        </div>
                                                        <span id="newcity"></span>
                                                        <span id="newcounty"></span>
                                                        <div id="error">
                                                            <td colspan='2'>{{session("info")}}
                                                                @if (count($errors) > 0)
                                                                <ul style='font:14px  宋体;color: rgba(222, 36, 14, 0.87);'>
                                                                    @foreach ($errors->all() as $error)
                                                                    <img style="float:left;" src="{{ asset('/dist/home/images/Cerror.jpg') }}"> <li>{{$error}}</li>
                                                                    @endforeach
                                                                </ul>
                                                                @endif
                                                            </td>
                                                        </div>
                                                    </div>
                                                    <div class="col-xs-12">
                                                        <span class="span_style" id="">详细地址</span>
                                                        <input class="input_style" type="text" name="addr_detail" id="address" value="" placeholder="&nbsp;&nbsp;请输入您的详细地址" />
                                                    </div>
                                                    <div class="col-xs-12">
                                                        <span class="span_style" id="">邮政编号</span>
                                                        <input class="input_style" type="text" name="addr_postcode" id="number_this" value="" placeholder="&nbsp;&nbsp;请输入您的邮政编号" />
                                                    </div>
                                                    <div class="col-xs-12">
                                                        <span class="span_style span_sty" id="">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</span>
                                                        <input class="input_style" type="text" name="addr_consignee" id="name_" value="" placeholder="&nbsp;&nbsp;请输入您的姓名" />
                                                    </div>
                                                    <div class="col-xs-12">
                                                        <span class="span_style" id="">手机号码</span>
                                                        <input class="input_style" type="text" name="addr_tel" id="phone" value="" placeholder="&nbsp;&nbsp;请输入您的手机号码" />
                                                    </div>
                                                    <div class="col-xs-12">
                                                        <input class="btn_remove" type="button" id="" onclick="javascript:onclick_close();" value="取消" />
                                                        <input type="submit" class="sub_set" id="sub_setID" value="提交" />
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                    {{--添加新地址结束--}}
                                    {{--回报错误--}}
                                    <div id="error">
                                        <td colspan='2'>{{session("info")}}
                                            @if (count($errors) > 0)
                                            <ul style='font:14px  宋体;color: rgba(222, 36, 14, 0.87);'>
                                                @foreach ($errors->all() as $error)
                                                <img style="float:left;" src="{{ asset('/dist/home/images/Cerror.jpg') }}"> <li>{{$error}}</li>
                                                @endforeach
                                            </ul>
                                            @endif
                                        </td>
                                    </div>
                                </div>
                                {{--回报错误结束--}}
                            </div>
                        </div>
                        <div class=mall_modw>
                            <div class=hd>
                                <h3>支付方式</h3></div>
                            <div class=bd>
                                <div class=onlinePay>
                                    <div class=formEle>
                                        <div class=eleRadio>
                                            <input type=radio checked name=payment class="hookbox ip" value="在线支付">
                                            <label class="djbls" style="width: 59.5px;">在线支付</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class=mall_modw>
                            <div class=hd>
                                <h3>配送方式</h3></div>
                            <div class=bd>
                                <div class=onlinePay>
                                    <div class=formEle>
                                        <div class=eleRadio>
                                            <input type=radio checked name=mailCharge class="hookbox ip" value="加配送费0元">
                                            <label class="djbls" style="width: 59.5px;">免费配送</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class=mall_modw>
                            <div class="hd nobdr">
                                <h3>商品清单</h3></div>
                            <div class=bd>
                                <div class=goodList>
                                    <div class="title">
                                        <div class=t1>商品名称</div>
                                        <div class=t2>单价</div>
                                        <div class=t3>数量</div>
                                        <div class=t4>合计</div></div>
                                    <div class="cont">
                                        <ul>
                                            @foreach($data as $tmp)
                                            <li>
                                                <div class="clearfix_new" style="padding:13px">
                                                    <div class=l1>
                                                        <img src="{{ $tmp->cart_img }}">
                                                        <span>{{ $tmp->goods_name }}</span>
                                                    </div>
                                                    <div class=l2>¥
                                                        <span class=sCount>{{ $tmp->cart_price }}</span>
                                                    </div>
                                                    <div class=l3>
                                                        <div class=gcIpt>×
                                                            <span>{{ $tmp->cart_num }}</span>
                                                        </div>
                                                    </div>
                                                    <div class=l4>¥
                                                        <span class="allCount">{{ $tmp->cart_price * $tmp->cart_num }}</span>
                                                    </div>
                                                </div>
                                            </li>
                                            @endforeach
                                        </ul>
                                    </div>
                                    <div class="total">
                                        <ul>
                                            <li>共<span id='gCount'></span>件</li>
                                            <li id="zCount">金额合计：元</li>
                                            <li class=bold>应付总额：
                                                <span id=tatalCount>¥0.00</span>元
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                                <a href="{{ url('/confirm/processing') }}" class=form_btn id=orderSubmit title="立即下单">立即下单</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{{--结束模板--}}
@endsection
@section('pluginscript')
<script type="text/javascript">
$(function(){
    // 获取数据
    var gCount = 0;
    var totalCount=0;
    $('.gcIpt span').each(function(i){
        gCount += parseInt($(this).text());
        totalCount += parseInt($('.allCount').eq(i).text());
    });
    $('#gCount').text(gCount);
    $('#zCount').text('金额合计：'+totalCount+'元');
    $('#tatalCount').text('¥'+totalCount);
});
</script>
<script type="text/javascript">
    $(function() {
        var region = $("#region");
        var address = $("#address");
        var number_this = $("#number_this");
        var name = $("#name_");
        var phone = $("#phone");
        $("#sub_setID").click(function() {
            var input_out = $(".input_style");
            for (var i = 0; i <= input_out.length; i++) {
                if ($(input_out[i]).val() == "") {
                    $(input_out[i]).css("border", "1px solid red");
                    return false;
                } else {
                    $(input_out[i]).css("border", "1px solid #cccccc");
                }
            }
        });
        var span_momey = $(".span_momey");
        var b = 0;
        for (var i = 0; i < span_momey.length; i++) {
            b += parseFloat($(span_momey[i]).html());
        }
        var out_momey = $(".out_momey");
        out_momey.html(b);
        $(".shade_content").hide();
        $(".shade").hide();
        $('.nav_mini ul li').hover(function() {
            $(this).find('.two_nav').show(100);
        }, function() {
            $(this).find('.two_nav').hide(100);
        })
        $('.left_nav').hover(function() {
            $(this).find('.nav_mini').show(100);
        }, function() {
            $(this).find('.nav_mini').hide(100);
        })
        $('#jia').click(function() {
            $('input[name=num]').val(parseInt($('input[name=num]').val()) + 1);
        })
        $('#jian').click(function() {
            $('input[name=num]').val(parseInt($('input[name=num]').val()) - 1);
        })
        $('.Caddress .add_mi').click(function() {
            $(this).css('background', 'url("/dist/home/images/a/mail_1.jpg") no-repeat').siblings('.add_mi').css('background', 'url("/dist/home/images/a/mail.jpg") no-repeat')
        })
    })
var x = Array();

function func(a, b) {
x[b] = a.html();
alert(x)
a.css('border', '2px solid #f00').siblings('.min_mx').css('border', '2px solid #ccc');
}

function onclick_close() {
var shade_content = $(".shade_content");
var shade = $(".shade");
if (confirm("确认关闭么！此操作不可恢复")) {
    shade_content.hide();
    shade.hide();
}
}

function onclick_open() {
$(".shade_content").show();
$(".shade").show();
var input_out = $(".input_style");
for (var i = 0; i <= input_out.length; i++) {
    if ($(input_out[i]).val() != "") {
        $(input_out[i]).val("");
    }
}
}

function onclick_remove(r) {
    if (confirm("确认删除么！此操作不可恢复")) {
        var out_momey = $(".out_momey");
        var input_val = $(r).parent().prev().children().eq(1).val();
        var span_html = $(r).parent().prev().prev().children().html();
        var out_add = parseFloat(input_val).toFixed(2) * parseFloat(span_html).toFixed(2);
        var reduce = parseFloat(out_momey.html()).toFixed(2)- parseFloat(out_add).toFixed(2);
        console.log(parseFloat(reduce).toFixed(2));
        out_momey.text(parseFloat(reduce).toFixed(2))
        $(r).parent().parent().remove();
    }
}
</script>
<script src="{{ asset('/dist/home/js/mall_monitor.js') }}"></script>

<script type="text/javascript" src="{{  asset('/dist/home/js/City/jQuery.js') }}"></script>
<script type="text/javascript" src="{{  asset('/dist/home/js/City/jquery.cityselect.js') }}"></script>
<script>
    $('.city_2').citySelect({prov: "北京", nodata: "none"});
    @foreach ($address as $addr)
    $('.city_edit_{{$addr->id}}').citySelect({prov: "{{$addr->addr_province}}", city:"{{$addr->addr_city}}",dist:"{{$addr->addr_county}}",nodata: "none"});
    @endforeach
</script>
<script>
//        $('.djbls').click(function () {
//            $("label").attr("border", "1px solid red");
//        });
    $(function() {

        $(".djbls").click(function() {

            $(this).css('border', '2px solid #82C92F');

        })
    });
</script>
<script>
$(function() {
    $('.action-edit').click(function(){
        $(this).parent('span').siblings('.mod-consignee-info').find('.consignee-add').slideToggle();
    });
});
$(function() {
    $(".cancel").click(function() {
        $(".consignee-add").slideUp("normal");
    });
});
$(function(){
    // 修改收货地址
    $('.addr_id').click(function(){
        var id = $(this).val();
        var token = "{{ csrf_token() }}";
        $.ajax({
            url: "{{ url('/order/changeaddress') }}",
            type:'POST',
            data:{id:id,_token:token},
            async:false,
            success:function(msg){
                if(msg.status != 1){
                    alert(msg.info);
                }
            }
        });
    })
});
</script>
@endsection